package controller;


import com.sun.net.httpserver.HttpServer;
import dao.impl.UpdateDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Date;

@WebServlet("/updatePhone.do")
public class UpdatePhone extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id= Integer.parseInt(req.getParameter("id"));
        String inventory=req.getParameter("inventory");
        String name=req.getParameter("name");
        String type=req.getParameter("type");
        String price=req.getParameter("price");
        UpdateDaoImpl updateDao=new UpdateDaoImpl();
        updateDao.updatePhone(name, Integer.parseInt(inventory),type, Double.parseDouble(price),id);
        req.getRequestDispatcher("/selectAllPhone.do").forward(req,resp);
    }
}
